node "default" {
  # edit puppet.conf file
  augeas { 'puppet.conf':
    context => '/files/etc/puppet/puppet.conf',
    changes => ["set main/color false",]
  }

  # add user
  $username='niemimac'
  user { $username:
    ensure     => present,
    # create password with command: echo "password"|openssl passwd -1 -stdin
    password   => '$1$7NmWrtwb$5SONsK8hdibq9yV5k1bbv.',
    groups     => [root],
    shell      => "/bin/bash",
    system     => true,
    managehome => true,
  }

  # add user to sudoers
  #  sudo::sudoers { 'sudoers':
  #    ensure   => 'present',
  #    users    => ['niemimac'],
  #    runas    => ['root'],
  #    cmnds    => ['ALL'],
  #    tags     => ['NOPASSWD'],
  #    defaults => ['env_keep += "SSH_AUTH_SOCK"']
  #  }

  # add sudoers file
  file { "/etc/sudoers":
    owner => "root",
    group => "root",
    mode  => "440",
  }

  # add user to sudoers
  augeas { 'sudoers':
    context => "/files/etc/sudoers",
    changes => [
      "set spec[user = '$username']/user $username",
      "set spec[user = '$username']/host_group/host ALL",
      "set spec[user = '$username']/host_group/command ALL",
      "set spec[user = '$username']/host_group/command/runas_user ALL",
      ],
  }

  # install tomcat
  #  package { "tomcat7": ensure => "installed" }
}
